<%-- 
    Document   : agregarUniversidad
    Created on : 07-22-2012, 01:37:53 PM
    Author     : Susy
--%>

<%@include file="/include/struts-tags.jsp" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.uca.sisbec.mapping.Carrera"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">



<html>
    <%@include file="/include/head.jsp" %>
    <script type="text/javascript" src="js/funciones-reunion.js"></script>
    <script type="text/javascript">
        function deshabilitar(codigo){
            var campos = codigo.split("|"); 
            //var url = getBaseURL();
            var url = "";
            var form = document.getElementById("UniversidadForm");
            if(campos[2]=='A'){
                if(!confirm("Seguro que desea Deshabilitar esta universidad?")){
                    return;
                }
                //url = url + "Universidad.jsa?cmd=InhabilitarUniversidad&cod="+campos[0];
                url = "./Universidad.jsa?cmd=InhabilitarUniversidad&cod="+campos[0];
            }else{
               if(!confirm("Seguro que desea Habilitar esta universidad?")){
                    return;
                }
                url = url + "Universidad.jsa?cmd=HabilitarUniversidad&cod="+campos[0];
            }
            form.action = url;
            form.submit();
        }
        
         function refresh(){
            var form = opener.document.getElementById("becarioForm");
            form.cmd.value = "refresh";
            var options = form.emails.options;
            var len = options.length - 1;
            var i = 0;
            for (i = len; i >= 0; i--)
                if (!options[i].selected)
                    options[i].selected = true;

            options = form.phones.options;
            len = options.length - 1;
            for (i = len; i >= 0; i--)
                if (!options[i].selected)
                    options[i].selected = true;
            form.submit();
        }
        
         function agregar(){
            var form = opener.document.getElementById("becarioForm");
            form.cmd.value = "GuardarUniversidad";
            var options = form.emails.options;
            var len = options.length - 1;
            var i = 0;
            for (i = len; i >= 0; i--)
                if (!options[i].selected)
                    options[i].selected = true;

            options = form.phones.options;
            len = options.length - 1;
            for (i = len; i >= 0; i--)
                if (!options[i].selected)
                    options[i].selected = true;
            form.submit();
        }
    </script>
    <body onunload="refresh();">
        <br />
        <html:form action="/Universidad" styleId="UniversidadForm">
            <html:hidden property="cmd" value="GuardarUniversidad" />
            <table class="form">
                <caption class="titleSeg">Universidades</caption>
                <tr class="campos">
                    <td class="label">Activo:&nbsp;&nbsp;</td>
                    <td class="control" colspan="4"><html:checkbox property="estado" styleClass="check" /></td>
                </tr>
                <tr class="campos"> 
                    <td class="label">Nombre:&nbsp;&nbsp;</td>
                    <td class="control"><html:text property="nombre" styleClass="tinput125"/></td>
                    <td width="25px"></td>
                    <td class="label">Formato Carnet:&nbsp;&nbsp;</td>
                    <td class="control"><html:text property="formatoCarnet" styleClass="tinput125"/></td>
                </tr>
                <tr>
                    <td colspan="5" align="center">
                        <html:submit value="Agregar" styleClass="button" />
                    </td>
                </tr>
                <logic:present name="msg">
                    <tr>
                        <td class="success" colspan="5">
                            <html:img src="./images/ok.png" />&nbsp;
                            <html:messages id="mensaje" name="msg">
                                <bean:write name="mensaje" />
                            </html:messages>
                        </td>
                    </tr>
                </logic:present>
                <logic:present name="errors">
                    <tr>
                        <td class="errors" colspan="5">
                            <html:img src="./images/error.png" />&nbsp;<html:errors name="errors" />
                        </td>
                    </tr>
                </logic:present>
            </table>
        </html:form>
        <br /><br />
        <logic:present name="UniversidadesList" scope="request">
            <display:table pagesize="10" name="UniversidadesList" requestURI="" class="results" style="width:90%;" id="results">
                <display:column property="universidad" title="Acción" decorator="com.uca.sisbec.decorators.UniversidadDecorator" sortable="true" />
                <display:column property="nombre" title="Nombre Universidad" sortable="true" />
                <display:column property="formatoCarnet" title="Formato Carnet" sortable="true" />
            </display:table>
        </logic:present>
        <script>
            var table = document.getElementById("results");
            var rows = table.getElementsByTagName("tr");
            for (var i = 1; i < rows.length; i++) {
                rows[i].onmouseover = function() {
                    this.className += ' hilite';
                }
                rows[i].onmouseout = function() {
                    this.className = this.className.replace(' hilite', '');
                }
            }
        </script>
    </body>
</html>
